package com.jd.finance.core.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jd.finance.core.pojo.dto.NoCheckLoanDTO;
import com.jd.finance.core.pojo.entity.LoanApply;
import com.jd.finance.result.BaseResult;
import org.apache.ibatis.annotations.Param;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;

/**
 * <p>
 * 贷款申请表 服务类
 * </p>
 *
 * @author LiQingBo
 * @since 2022-05-25
 */
public interface LoanApplyService extends IService<LoanApply> {

    BaseResult getSumLoanMonth(@Param("uid") Integer uid);

    /**
     * 获取未审核贷款的 申请
     *
     * @param pageParam
     * @return
     */
    Page<NoCheckLoanDTO> getNoAuditLoan(@Param("pageParam") Page<NoCheckLoanDTO> pageParam);

    /**
     * 根据贷款申请id，获取贷款申请详情
     *
     * @param uid
     * @param loanAppId
     * @return
     */
    BaseResult getApplyLoanInfo(@Param("uid") Integer uid, @Param("loanAppId") Integer loanAppId);

    /**
     * 获取所有第一轮通过的申请
     *
     * @param pageParam
     * @return
     */
    IPage<LoanApply> listPage(@Param("pageParam") Page<LoanApply> pageParam);

    /**
     * 根据贷款申请id，获取贷款申请详情
     *
     * @param loanAppId
     * @return
     */
    BaseResult getAllApplyInfo(@Param("loanAppId") Integer loanAppId);


    /**
     * 根据贷款申请id，修改风控状态 通过
     *
     * @param uid
     * @param loanAppId
     * @param riskId
     * @param riskName
     * @param isPass
     * @param message
     * @param isTop
     * @param topRate
     * @param agreeMoney
     * @param request
     * @return
     */
    BaseResult passRisk(@Param("uid") Integer uid, @Param("loanAppId") Integer loanAppId, @Param("riskId") Integer riskId, @Param("riskName") String riskName,
                        @Param("isPass") Integer isPass, @Param("message") String message,
                        @Param("isTop") Integer isTop, @Param("topRate") BigDecimal topRate,
                        @Param("agreeMoney") BigDecimal agreeMoney, HttpServletRequest request);


    /**
     * 根据 贷款申请id， 修改 审核状态
     *
     * @param uid
     * @param loanAppId
     * @param loanStatus
     * @param noPassInfo
     * @param auditorId
     * @param auditorName
     * @param request
     * @return
     */
    BaseResult updateCheckStatus(@Param("uid") Integer uid, @Param("loanAppId") Integer loanAppId, @Param("loanStatus") String loanStatus, @Param("noPassInfo") String noPassInfo, @Param("auditorId") Integer auditorId, @Param("auditorName") String auditorName, @Param("request") HttpServletRequest request);

    /**
     * @param uid
     * @param loanAppId
     * @param riskId
     * @param riskName
     * @param isPass
     * @param message
     * @param request
     * @return
     */
    BaseResult noPassRisk(@Param("uid") Integer uid, @Param("loanAppId") Integer loanAppId, @Param("riskId") Integer riskId, @Param("riskName") String riskName,
                          @Param("isPass") Integer isPass, @Param("message") String message, HttpServletRequest request);

    /**
     * 获取所有风控员信息
     *
     * @return
     */
    BaseResult getAllRiskManList();

    /**
     * 贷款申请（贷款银行id，产品id，个人身份证号或企业法人身份证号，开户人（必须和企业法人身份证号一致），卡号，开用户整体负债）
     * @param bid       银行id
     * @param proId    产品id
     * @param workId    工作人员id
     * @param no        身份证/法人身份证号
     * @param userName  开户人
     * @param loanReason 贷款申请原因
     * @param cardNum   卡号
     * @param allDebt   所有负债
     * @return          提交结果
     */
    BaseResult applyLoan(@Param("bid") Integer bid, @Param("proId") Integer proId,
                         Integer workId, @Param("no") String no, @Param("userName") String userName,
                         @Param("loanReason") String loanReason, @Param("cardNum") String cardNum,
                         @Param("allDebt") BigDecimal allDebt);
    /**
     * 根据贷款申请id，修改申请状态及时间
     *
     * @param uid
     * @param loanAppId
     * @param request
     * @return
     */
    BaseResult updateApplStatus(@Param("uid") Integer uid, @Param("loanAppId") Integer loanAppId, @Param("request") HttpServletRequest request);

    /**
     * 根据贷款申请id,获取贷款申请详情
     *
     * @param loanAppId 贷款申请id
     * @param uid       信贷员id
     * @return
     */
    BaseResult getLoanDetailInfo(Integer loanAppId, Integer uid);

    /**
     *查看已签署协议的贷款申请
     * @param officerId
     * @param page
     * @param limit
     * @return
     */
    BaseResult getSignedLoanApp(@Param("officerId") Integer officerId, @Param("page") Long page, @Param("limit") Long limit);
}
